import logging

logger = logging.getLogger(__name__)

config = \
{
    "version": 1,
    "formatters":{
        "normal-fmt":{
            "format": "日志时间【%(asctime)s】 - 日志名称【%(name)s】 - 文件【%(filename)s】 - 第【%(lineno)d】行 - 日志等级【%(levelname)s】 - 日志信息【%(message)s】",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "func-fmt":{
            "format":"%(asctime)s - %(name)s - %(filename)s - %(funcName)s - %(lineno)d - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "traceback-fmt":{
            "format":"%(asctime)s - %(name)s - 【 File '%(pathname)s', line %(lineno)d, in %(funcName)s 】 - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "best-fmt":{
            "format":"%(asctime)s - %(name)s - '%(pathname)s:%(lineno)d' - %(funcName)s - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "shortfile-fmt":{
            "format":"%(asctime)s - %(name)s - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "best-fmt-plus":{
            "format":"[p%(process)d_t%(thread)d] %(asctime)s - %(name)s - '%(pathname)s:%(lineno)d' - %(funcName)s - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        },
        "shortfile-fmt-plus":{
            "format":"[p%(process)d_t%(thread)d] %(asctime)s - %(name)s - '%(filename)s:%(lineno)d' - %(levelname)s - %(message)s",
            "datefmt":"%Y-%m-%d %H:%M:%S"
        }

    },
    "handlers":{
        "console":{
            "class": "logging.StreamHandler",
            "level": "DEBUG",
            "formatter":"shortfile-fmt",
            "stream": "ext://sys.stdout"
        },
        "colorHandler":{
            "class": "app.utils.log_handle.colorHandler",
            "level": "DEBUG",
            "formatter": "best-fmt",
            "stream": "ext://sys.stdout"
        },
        "socketHandler":{
            "class": "logging.handlers.SocketHandler",
            "level": "NOTSET",
            "formatter":"best-fmt",
            "port":"9020",
            "host":"localhost"			
        },
        "itemsHandler":{
            "class":"logging.handlers.RotatingFileHandler",
            "level":"DEBUG",
            "formatter":"shortfile-fmt",
            "filename":"logs/items.log",
        },
        "appHandler":{
            "class":"logging.handlers.RotatingFileHandler",
            "level":"DEBUG",
            "formatter":"shortfile-fmt",
            "filename":"logs/app.log",
        },
        "testHandler":{
            "class":"logging.handlers.RotatingFileHandler",
            "level":"DEBUG",
            "formatter":"shortfile-fmt",
            "filename":"logs/test.log",
        },
    },
    "loggers":{
        "simpleExample":{
            "level":"DEBUG",
            "handlers":["colorHandler","socketHandler"],
            "propagate": 0
        },
        "items":{
            "level":"DEBUG",
            "handlers":["colorHandler","itemsHandler"],
            "propagate": 0
        },
        "app":{
            "level":"DEBUG",
            "handlers":["colorHandler","appHandler"]
        }
    }
}